<?php
declare (strict_types=1);

namespace app\admin\controller;

use app\admin\service\AuthService;
use think\response\Json;

class Index extends AdminBaseController
{
    // 无需验证登录
    protected $allowAllAction = [
        'Index/loginBySmsCode',
    ];

    // 强制验证当前访问的控制器方法method
    protected $methodRules = [
        'loginBySmsCode' => 'POST',
        'logout' => 'GET',
    ];

    // 短信验证码登录
    public function loginBySmsCode(): Json
    {
        $AuthService = new AuthService;
        $res = $AuthService->loginBySmsCode($this->request->post());
        return json($res);
    }

    // 退出登录
    public function logout(): Json
    {
        $AuthService = new AuthService;
        $AuthService->logout();
        return json(render_array_success());
    }
}
